function checkFormLoad(executeNum, callback, maxNum = 10) {
  if (executeNum >= maxNum) {
    console.log('10秒过去了，但没有检查到内容')
    return
  }
  setTimeout(() => {
    var data = $("#nc_1_wrapper").html();

     console.log("checkFormLoad_");
     console.log(data);

    if (data.length>0) {
      var top = $("#nc_1_n1z").offset().top;
      var left = $("#nc_1_n1z").offset().left
     console.log('top_'+top+"_left_"+left)

      callback(1)
    } else {
        console.log((executeNum + 1)+ '+1秒过去了，内容有错误')
        checkFormLoad(executeNum + 1, callback)
    }
  }, 1000);
}

function login(i) {
   if(i==1){
     $("#nc_1_n1z").click();
     $("#nc_1_n1z").mousedown();
   }
   if(i>335){
     $("#nc_1_n1z").mouseup();

     $("#nc_1__bg").attr("style","width: 330px;");
     $("#nc_1_n1z").attr("style","left: 330px;");
     return;
   }
   setTimeout(() => {
        $(document).mouseXPos(665);
        $(document).mouseYPos(420);

        $("#nc_1_n1z").mousemove();
        $("#nc_1__bg").attr("style","width: "+i+"px;");
        $("#nc_1_n1z").attr("style","left: "+i+"px;");

        var randn= Math.floor(Math.random()*5+5) + Math.ceil(Math.random()*10)/10;
         console.log("login_randn_"+randn);
        login(i+randn);
     }, 100);
}

checkFormLoad(0,login)

chrome.runtime.onMessage.addListener(async (msg, sender) => {
  console.log(msg)
})


$(document).mousemove(function(event){
    console.log(event.pageX + ", " + event.pageY)
});